//
//  MeBtnListInfoView.m
//  Ginix
//
//  Created by 冯志强 on 2025/3/6.
//

#import "MeBtnListInfoView.h"
#import "MeListBtnCell.h"
@interface MeBtnListInfoView()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionView   * listView;

@end

@implementation MeBtnListInfoView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    [self addSubview:self.listView];
    [_listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

    return 1;
}

-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    MeListBtnCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MeListBtnCell" forIndexPath:indexPath];
    [cell setHeadIndex:indexPath.row];
    return cell;
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{

    return UIEdgeInsetsMake(0* FMScaleX, 10* FMScaleX, 0* FMScaleX, 10* FMScaleX);
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        id vc = [[NSClassFromString(@"HealthReportsVC") alloc]init];
        [[UIViewController findNavigationController] pushViewController:vc animated:YES];
    }
    if (indexPath.row == 1) {
        id vc = [[NSClassFromString(@"MeHealthOrderVC") alloc]init];
        [[UIViewController findNavigationController] pushViewController:vc animated:YES];
    }
    if (indexPath.row == 2) {
        id vc = [[NSClassFromString(@"OnlineChattingVC") alloc]init];
        [[UIViewController findNavigationController] pushViewController:vc animated:YES];
    }
//    if (indexPath.row == 3) {
//        id vc = [[NSClassFromString(@"MeAddressVC") alloc]init];
//        [[UIViewController findNavigationController] pushViewController:vc animated:YES];
//    }
  
}

-(UICollectionView *)listView{

    if (!_listView) {
        UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
        layout.itemSize = CGSizeMake(50 * FMScaleX, 75 * FMScaleX);

        _listView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        _listView.delegate = self;
        _listView.dataSource = self;
        _listView.backgroundColor = UIColor.clearColor;
        _listView.showsVerticalScrollIndicator = NO;
        _listView.showsHorizontalScrollIndicator = NO;
        [_listView registerClass:[MeListBtnCell class] forCellWithReuseIdentifier:@"MeListBtnCell"];

    }
    return _listView;
}
@end
